package com.project;


import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Service;
import util.BaseImg64;

import java.io.IOException;

@Service
public class MovieService {
    @RabbitListener(queues = "picQueue")
    public void getOrder(String str64, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) throws IOException {
        System.out.println("监听成功");
        if (null != str64) {
            //转化base64至图片
            BaseImg64.convertBase64UrlDataToImage(str64, "e:/img3/" + Math.random() + System.currentTimeMillis() + ".jpg");
            channel.basicAck(tag, false);
            System.out.println("转换成功");
        }
    }

    @RabbitListener(queues = "picQueueDead")
    public void getOrder(String str64) {
        System.out.println("进入死信队列");
        //消耗掉死信信息
        System.out.println(str64);
    }
}
